#include <iostream>
#include <string>
#include <cctype>
#include "stack.h"
int main_stacker()
{
    using namespace std;
    const string hint = "Please input the task you want to do: A to append, P to pop, and Q to quit the program";
    cout << hint << endl;
    char input;
    Stack aStack;
    while (cin >> input && toupper(input) != 'Q')
    {
        cout << "input=[" << input << "]" << endl;
        if (!isalpha(input))
        {
            continue;
        }
        // 如果输入的是多个字符，则再次处理
        if (cin.get() != '\n')
        {
            continue;
        }

        switch (input)
        {
        case 'A':
        case 'a':
        {
            if (aStack.isFull())
            {
                cout << "Stack is full !" << endl;
                continue;
            }
            cout << "Please input the number you want to append" << endl;
            Item toAppend;
            cin >> toAppend;
            aStack.push(toAppend);
            cout << "append ..." << endl;
        }
        break;
        case 'P':
        case 'p':
        {
            if (aStack.isEmpty())
            {
                cout << "Stack is empty !" << endl;
                continue;
            }
            Item toPoped;
            aStack.pop(toPoped);
            cout << "poped item " << toPoped << endl;
        }
            aStack.display();
            cout << hint << endl;
        }

        cout << "exit ..." << endl;
        return 0;
    };
}